import tornado.web
import tornado.ioloop
from skills.xunfeidb import DbHelper
from skills import *

#定义处理类型
class IndexHandler(tornado.web.RequestHandler):
    #添加一个处理get请求方式的方法
    def get(self):
        #向响应中，添加数据
        self.write('fake xunfei server')



if __name__ == '__main__':
    g_db = DbHelper()

    routes = [
        (r'/',IndexHandler),
        (r'/face/addDb', FaceAddDb),
        (r'/face/addFace', FaceAddFace),
        (r'/face/clearDbFaces', FaceclearDbFaces),
        (r'/face/deleteDb', FacedeleteDb),
        (r'/face/deleteFace', FaceDeleteFace),
        (r'/face/detectAndQuality', FaceDetectAndQuality),
        (r'/face/faceSearch', FaceSearch),
        (r'/face/faceVerification', FaceVerification),
        (r'/face/getFeature', FaceGetFeature),
        (r'/face/featureSearch', FaceFeatureSearch),

        (r'/pic/classify', PicClassify),
        (r'/pic/detect', PicDetect),
        (r'/pic/iicd', PicIICD),

        (r'/receive/aas', receive_aas, dict(db=g_db)),
        (r'/receive/aasSyncSearch', receive_aasSyncSearch),
        (r'/receive/addAasDb', receive_addAasDb),
        (r'/receive/comparemodel', receive_comparemodel),
        (r'/receive/deleteAasDb', receive_deleteAasDb),
        (r'/receive/ist/decode', receive_istdecode),
        (r'/receive/model', receive_model, dict(db=g_db)),
        (r'/receive/syncDecode', receive_syncDecode),
        (r'/receive/syncGetModelStr', receive_syncGetModelStr),
        (r'/receive/syncIst', receive_syncIst),
        (r'/receive/syncVspp', receive_syncVSpp),

        (r'/txt/its', txtIts),
        (r'/txt/ltr', txtLtr),
        (r'/txt/quickits', txtQuickits),
        (r'/txt/searchKeyword', txtSearchKeyword),
        (r'/txt/tic', txtTic),



    ]
    #创建一个应用对象
    app = tornado.web.Application(routes)
    #绑定一个监听端口
    app.listen(8888)
    #启动web程序，开始监听端口的连接
    print('started at 0.0.0.0:8888')
    tornado.ioloop.IOLoop.current().start()


